<template>
  <Modal v-model="info.show" title="新增学生" :mask-closable="false" :width="600" :styles="{top: '10px'}" :closable="false">
    <!--      {{this.desc}}-->
    <Form>
      <FormItem label="学生姓名:" style="display: inline-flex; margin-right: 5px">
        <Input v-model="formInfo.username" type="text" style="width: 150px"/>
      </FormItem>
      <FormItem label="手机号码:" style="display: inline-flex; margin-left: 10px">
        <Input v-model="formInfo.phone" type="text" style="width: 150px"/>
      </FormItem>
    </Form>
    <Form>
      <FormItem label="招生教师:" style="display: inline-flex; margin-right: 5px">
        <Input v-model="formInfo.teacher_name" type="text" style="width: 150px"/>
      </FormItem>
      <FormItem label="教师工号:" style="display: inline-flex; margin-left: 10px">
        <Input v-model="formInfo.teacher_no" type="text" style="width: 150px"/>
      </FormItem>
    </Form>
    <Form>
      <FormItem label="报考专业:" style="display: inline-flex; margin-right: 5px">
        <Input v-model="formInfo.major" type="text" style="width: 150px"/>
      </FormItem>
      <FormItem label="毕业学校:" style="display: inline-flex; margin-left: 10px">
        <Input v-model="formInfo.school" type="text" style="width: 150px"/>
      </FormItem>
      <FormItem label="身份证号:" style="display: inline-flex; margin-right: 5px">
        <Input v-model="formInfo.cert_no" type="text" style="width: 385px"/>
      </FormItem>
      <FormItem label="备注信息:" style="margin-right: 10px">
        <Input v-model="formInfo.add_info" type="textarea" :rows="4" style="width: 385px"/>
      </FormItem>
    </Form>
    <div slot="footer">
      <Button type="info" @click="cancel(false)">取消</Button>
      <Button type="warning" :loading="loading" @click="save"> 保存</Button>
    </div>
  </Modal>
</template>

<script>
import { post, baseUrl} from '@/libs/axios-cfg'
import { formatDate } from '@/libs/util'
export default {
  name: "student_add",
  props:{
    info:{
      type:Object
    }
  },
  data() {
    return {
      loading: false,
      formInfo: {
        username: '',
        teacher_name: '',
        teacher_no: '',
        school: '',
        major: '',
        phone: '',
        cert_no: '',
        add_info: ''
      }
    }
  },
  methods: {
    async save() {
      console.log("save");
      try {
        this.loading = true;
        let res = await post('/rank/student/add', {
          username: this.formInfo.username,
          teacherName: this.formInfo.teacher_name,
          teacherNo: this.formInfo.teacher_no,
          phone: this.formInfo.phone,
          major: this.formInfo.major,
          school: this.formInfo.school,
          certNo: this.formInfo.cert_no,
          addInfo: this.formInfo.add_info
        });
        if (res.status == 1) {
          this.$Message.info("添加成功");
          this.info.show = false;
          this.$emit('update_table');
        }
      } catch (error) {
        this.$throw(error)
      } finally {
        this.loading = false;
      }
    },
    cancel() {
      console.log("cancel");
      this.info.show = false;
    }
  },
  created() {
  }
}
</script>

<style scoped>

</style>
